<template>
    <div>
          <news-detail :detail="newinfo"></news-detail>
          <news-comment :id="id" :url="'api/getcomments'"></news-comment>
    </div>
</template>

<script>
//引入组件
import newDetail from '../common/Detail.vue'
import newComment from '../common/Comment.vue'
export default {
    data() {
        return {
            id: this.$route.params.id,
            newinfo:{}
        }
    },
    created() {
        this.getNewinfo()
    },
    methods: {
        getNewinfo(){
            this.$http.get('api/getnew/'+this.id).then(result=>{
                if(result.body.status === 0){
                    this.newinfo = result.body.message.length>0?result.body.message[0]:{}
                }else{
                    this.$toast('文章详情加载失败:'+result.body.message)
                }
            })
        }
    },
    components:{
        'news-detail':newDetail,
        'news-comment':newComment,
    }
}
</script>

<style lang="less" scoped>

</style>